#pragma once
#include <vector>
#include <d3dx9.h>
#include "GameState.h"
#include "Utils.h"
#include "TextureManager.h"
#include "GameRun.h"
#include "GameMenu.h"
#include "dinput.h"

using namespace std;

class GameMenu;
class GameRun;
class GameManagement
{
protected:
	LPDIRECT3DDEVICE9 *_d3ddv;
	LPD3DXSPRITE *_spriteHandler;
	LPDIRECT3DSURFACE9 *_background;

	GameState *_currentState;
	vector<GameState*> *_states;

	GameMenu* _gameMenu;
	GameRun* _gameRun;
	long _timeMenuCounter, _timeRunCounter;

	void _initGameState();
public:
	GameManagement(int state, 
		LPDIRECT3DDEVICE9 &d3ddv, 
		LPD3DXSPRITE &spriteHandler, 
		LPDIRECT3DSURFACE9 &backgroud);
	~GameManagement();

	void updateGameMenu();
	void updateGameRun();
	void update();

	void setBackground(int state);
	void setState(int state);
	void setInput(int keycode, bool onHold);
	GameMenu* getGameMenu();	

	LPD3DXSPRITE getSpriteHandler() { return *_spriteHandler; }
	LPDIRECT3DSURFACE9 getBackground() { return *_background; }
	LPDIRECT3DDEVICE9 getDevice() { return *_d3ddv; }

	void draw();
	void drawGameMenu();
	void drawGameRun();

	GameRun* getGameRun() { return _gameRun; }
};

  